#!/usr/bin/python
#-*-coding: utf-8 -*-

__all__ = [u'GuiPart']

########## DO NOT CHANGE THESE LINES ###########################################
import sys
from pylot.core import (ENCODING, Path)
try : __file__
except NameError : co = sys._getframe(0).f_code ; __file__ = co.co_filename
ufile = __file__.decode(ENCODING)
if ufile.strip() : PLUGIN_PATH = Path(ufile).abspath().parent
else : PLUGIN_PATH = Path(u'.').abspath()
########## DO NOT CHANGE THESE LINES ###########################################

from PyQt4 import QtGui
from PyQt4.QtCore import SIGNAL

from pylot.core import (check_type, Datum, DirPath)
from pylot.qtgui import (load_designer_file, GuiAutoWidget,
                                 GuiPathChooser, GuiCollectionEditor)

from handler import HandlerPart

_GuiPart, WidgetClass = load_designer_file(u'designer.ui', [PLUGIN_PATH])
class GuiPart(WidgetClass, GuiAutoWidget, _GuiPart):
  u"""
  Translation tool
  """
  def __init__(self, handler=None):
    if handler is None :
      handler = HandlerPart()
    GuiAutoWidget.__init__(self, handler)
    self._plugin_path = PLUGIN_PATH

    WidgetClass.__init__(self)
    self.setupUi(self)

    plugin = self.handler.opt[u'lastpaths'][u'plugins']
    self.widget_path = GuiPathChooser(plugin, handler=self.handler)
    self.addpyLotWidget(self.widget_path)
    self.layout.addWidget(self.widget_path)
    self.layout.addStretch()

    self._createConnexions()
    self._createMenus()
    self._createToolBars()
    self._createPreferences()

  def _createConnexions(self):
    # GUI only actions
    self.connect(self.action_open, SIGNAL('triggered()'),
                 self.widget_path.chooseDir)

  def _createMenus(self):
    self.menu_file = QtGui.QMenu()
    self.menu_file.setObjectName(u'menu_file')
    self.addMenu_(self.menu_file)

    self.menu_testing = QtGui.QMenu()
    self.menu_testing.setObjectName(u'menu_testing')
    self.addMenu_(self.menu_testing)

  def _fillMenus(self, level):
    self._fill(self.menu_file, [
      self.action_open,
      ])

  def _createToolBars(self):
    self.tool_bar_testing = QtGui.QToolBar()
    self.tool_bar_testing.setObjectName(u'tool_bar_testing')
    self.addToolBar_(self.tool_bar_testing)

  def _fillToolBars(self, level):
    pass

  def _decorate (self):
    pass

  def _translate(self):
    self._setTexts([
      (self, self.tr_(u'Testing tools')),
      (self.tool_bar_testing, self.tr_(u'Testing ToolBar')),
      (self.menu_testing, self.tr_(u'Tests')),
      (self.menu_file, self.tr_(u'File'))
      ])

  def _createPreferences(self):
    self.pref = GuiCollectionEditor(self.handler.opt[u'doctests'],
      handler=self.handler)

if __name__ == u"__main__":
  pass
